<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子36-ES6/7常用语法介绍</title>
    </head>

    <body>
        <pre>
            <code>
                // 例子36

                // 拷贝对象
                let x = {a: 1, b: 2};
                let y = {...x}; // 等同于let y = Object.assign({}, x);
                console.log(y); // {a: 1, b: 2}

                //--------------------------------------------------------------------------

                // 合并多个对象(重复值覆盖)
                let x = {a: 1, b: 2};
                let y = {b: 3, c: 4};
                let z = {c: 5, d: 6};
                let xyz = {...x, ...y, ...z}; // 等同于let xyz = Object.assign({}, x, y, z);
                let w = {...x, c: 10, e: 8, ...z}; // 等同于let w = Object.assign({}, x, {c: 10, e: 8}, z);
                console.log(xyz); // {a: 1, b: 3, c: 5, d: 6}
                console.log(w); // {a: 1, b: 2, c: 5, e: 8, d: 6}
            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/36.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>

</html>